#include "ModifyTextCmd.h"

#include "../model/UMLObject.h"

#include <stdexcept>

ModifyTextCmd::ModifyTextCmd(UMLObject* target, const QString& text)
:	Command(),
	_target(target),
	_text(text) // copy-on-write is beautiful *sniff*
{
	if (!target)
		throw std::domain_error("Cannot modfiy a NULL UMLObject.");
}

void ModifyTextCmd::execute()
{
	// TODO: store old text later
	// _oldtext = _target->text().fullText();
	_target->setText(_text); // constructs temporary BUMLSText
}

void ModifyTextCmd::unexecute()
{
	// TODO
	_target->setText(_oldtext);
}

